<div class="container">

<?php echo $this->session->flash(); ?>

<div class="panel panel-default">
	<table class="table">
		<thead>
			<tr>
				<th>#</th>
				<th>Contact Name</th>
				<th>Contact Email</th>
				<th>Contact Message</th>
				<th>Create Date</th>
				<th>Status</th>
				<th></th>
			</tr>
      	</thead>
      
		<tbody>
		
			<?php $index = 0; foreach($list as $item): $index++; ?>
			
				<?php if($index % 2 != 0) { ?>
					<tr class="info">
				<?php } else { ?>
					<tr>
				<?php } ?>
				
					<td>
						<a href="<?php echo $this->webroot; ?>contact/detail?id=<?php echo $item['Contact']['id']; ?>" ><?php echo $item['Contact']['id']; ?></a>
					</td>
					
					<td>
						<a href="<?php echo $this->webroot; ?>contact/detail?id=<?php echo $item['Contact']['id']; ?>" ><?php echo $item['Contact']['name']; ?></a>
					</td>
					
					<td>
						<?php echo $item['Contact']['email']; ?>
					</td>
					
					<td>						
						<?php if(strlen($item['Contact']['message']) > 50) { ?>
							<?php echo substr($item['Contact']['message'],0, 50); ?>...
						<?php } else { ?>
							<?php echo $item['Contact']['message']; ?>
						<?php } ?>
												
					</td>
					
					<td>						
						<?php echo $item['Contact']['create_time']; ?>					
					</td>
					
					<td>						
						<?php if($item['Contact']['read_status'] == 1) { ?>
								<span class="label label-default">Read</span>
						<?php } else { ?>
							<span class="label label-info">New</span>
						<?php } ?>				
					</td>
					
					<td>
						<a onClick="return confirm('Delete this message ?');" href="<?php echo $this->webroot; ?>contact/delete?id=<?php echo $item['Contact']['id']; ?>">
							<button type="button" class="btn btn-danger">Delete</button>
						</a>
					</td>
				</tr>	
			<?php endforeach; ?>
			
		</tbody>
    </table>
</div>
</div>